<?php
session_start();
if (!$_SESSION['connect']) {
    include('intruder.php');
} else {
    include('header.php');
    $token = hash("sha512", mt_rand(0, mt_getrandmax()));
    $_SESSION['token'] = $token;
    $_SESSION['time'] = time();
}
?>
<script src="provider.js"></script>
<h3 style="text-align:center"><?php echo('Welcome ' . $_SESSION['name']); ?></h2>
<a href="logout.php">Logout</a>
<div id ="existing_services" style="text-align:left">
    <ul>Your services:
        <?php
        include('db_connect.php');
        $req = 'SELECT type, location, description, price FROM services WHERE provider_id = "' . $_SESSION['id'] . '" ORDER BY type, price DESC';
        $res = mysql_query($req);
        mysql_close();
        while ($rec = mysql_fetch_assoc($res)) {
            echo('<li>' . $rec['type'] . ' [' . $rec['location'] . ']: ' . $rec['description'] . ' --- $' . $rec['price'] . '</li>');
        }
        ?>
    </ul>
</div>
<script>
    var token3 = "<?php echo($token); ?>";
</script>
<div id ="service_add" style="text-align:center">
    <form method="post" name="add_service_form" >
        <p style="padding:10px">Provide a new service:
        <pre>
  Hotel room <input type="radio" name="service_type" value="hotel"><br/>
  Restaurant <input type="radio" name="service_type" value="food"><br/>
  Car rental <input type="radio" name="service_type" value="car"><br/>
    Location <input type="text" id="service_location"><br/>
 Description <textarea id="service_descr" name="descr" cols=30 rows=3></textarea><br/>
       Price <input id="service_price" type="text" name="price" cols=10/>&nbsp;$<br/>
             <button type="button" onclick="add_service();">Send</button>
        </pre>
        </p>
    </form>
</div>
</body>
</html>